package com.lb.lb_ad_demo;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.lb.ad.ADv;
import com.lb.ad.cb.AdInterFace;
import android.util.Log;



public class SpActivity extends Activity {

    private final String TAG = "LBAD_SP";
    FrameLayout mSpLayout;
    private boolean isShowing = false;
     @Override
    protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
        setContentView( R.layout.activity_sp);

         mSpLayout = findViewById( R.id.splash_container);

         //防止重复创建的问题
         if (!isTaskRoot() && getIntent().hasCategory(Intent.CATEGORY_LAUNCHER)
                 && getIntent().getAction() != null
                 && getIntent().getAction().equals(Intent.ACTION_MAIN)) {
             finish();
             return;
         }

         ADv.showSp(LBAD_Config.SP_ID, SpActivity.this, mSpLayout, new AdInterFace.spCallBack() {
             @Override
             public void spEnd(String code, String msg, boolean isErr) {
                 Log.e(TAG,"开屏关闭 "+ msg +" isErr "+isErr);
                 finish();
                 StartMainAct(SpActivity.this);
                 isShowing = false;
             }

             @Override
             public void spShow() {
               Log.e(TAG,"开屏展示");
                 isShowing = true;
             }

             @Override
             public void spClick() {
                  Log.e(TAG,"开屏用户点击");

             }
         });
      }

    public  static void StartSpAct(Activity activity){
        Intent intent = new Intent();
        intent.setClass(activity, SpActivity.class);
        activity.startActivity(intent);
    }

    public  static void StartMainAct(Activity activity){
        Intent intent = new Intent();
        intent.setClass(activity, MainActivity.class);
        activity.startActivity(intent);
    }


    @Override
    protected void onResume() {
        super.onResume();
        //开屏广告onResume处理
        ADv.spOnResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        //开屏广告onPause处理
        ADv.spOnPause();
    }


}
